home *** CD-ROM | disk | FTP | other *** search
- /*
- * DTSSampleCSAM.h
- * Copyright © 1992-93 Apple Computer Inc. All Rights Reserved.
- */
- #ifndef __DTSSampleCSAM__
- #define __DTSSampleCSAM__
- #ifdef REZ
- #define IsResource 1
- #else
- #define IsResource 0
- #endif
-
- #if IsResource == 0
- #include <OCETemplates.h>
- #include <Files.h>
- #include <OSUtils.h>
- #include <ToolUtils.h>
- #include <Devices.h>
- #include <Types.h>
- #include <Aliases.h>
- #include <Memory.h>
- #include <Errors.h>
- #include <Icons.h>
- #include <Resources.h>
- #include <OCE.h>
- #include <OCEErrors.h>
- #include <OCEAuthDir.h>
- #include "Audit.h"
- #include "DETUtilities.h"
- #endif
-
- /*
- * This should match the latest AOCE release that this was tested with.
- */
- #define kMajorVersion 1
- #define kMinorVersion 0
- #define kReleaseStage final /* In <SysTypes.r> */
- #define kPreReleaseNumber 0
- #define kReleaseVersionString "1.0"
- /*
- * MPW defines this in the MakeFile. Define it here for Think C,
- * and make sure it's correct for MPW.
- */
- #ifndef kCSAMCreatorID
- #define kCSAMCreatorID 'Pdsm'
- #elif kCSAMCreatorID != 'Pdsm'
- << error, the above won't work >>
- #endif
- /*
- * kTemplateName is the name (user-visible) of the CSAM. It is really only used by
- * DTSSampleCSAMTemplate.r, but is defined here so that it can be included in the
- * Creator resource. kTemplateName is also used by AuthAddToLocalIdentityQueue.
- * Note that it is constant C-string. It must be duplicated as MPW Rez does not
- * support token pasting.
- */
- #define kTemplateName "DTS Sample CSAM"
- #define pTemplateName "\pDTS Sample CSAM" /* Thanks MPW */
-
-
- #if TRUE != 1
- #define TRUE 1
- #define FALSE 0
- #endif
-
- /*
- * Constants for the CSAM template. These are used by the C and Rez modules. They
- * assume the following directory structure:
- * :...:DTSSampleCSAM ƒ
- * MakeFile
- * DTS Sample Icons
- * Src
- * DTSSampleCSAM.h
- * All .c .h .r
- * Obj
- * All objects and linked code segments are written here
- */
-
- /*
- * These are used in the Rez and DTS_CSAMTemplate.c files.
- */
- #define kCSAMAspect kDETFirstID
- #define kCSAMInfoPage kDETSecondID
-
- #define prCreatePDButton (kSAMFirstDevProperty + 1)
- #define prHasCatalog (kSAMFirstDevProperty + 2)
- #define prPDAlias (kSAMFirstDevProperty + 3)
-
- /*
- * STR# kCSAMPromptStrings has prompt strings used in DTS_CSAMTemplate.c
- */
- #define kCSAMPromptStrings 128
- #define kNewPDPrompt 1
- #define kNewPDName 2
-
- /*
- * General Constants
- */
- #define kIconID (kCSAMAspect + kDETAspectMainBitmap)
- #define kDriverName 128
- #define kCSAMName 129 /* GetString(kCSAMName) has CSAM name */
- /*
- * The attribute type in which we store the alias to the Personal Catalog associated
- * with this Sample Catalog. Unfortunately, storing it in the resource file doesn't
- * seem to work (probably because the current resource file is pointing to the
- * wrong place). Note that it is a C string. AddCatalog.c converts it to an RString.
- */
- #define kPDAliasAttrTypeBody "Personal Catalog Alias"
-
- /*
- * These are the capabilities we provide: the application programmer accesses these
- * by calling Gestalt. The actual values are specific to the particular CSAM. For
- * this sample, we just copied the values from the Personal Catalog that the CSAM
- * shadows.
- *
- * Note: we also suppor kSupportsFindRecordMask -- this is handled internally
- * to the CSAM by enumerating through the personal catalog.
- */
- #define kMyFeatures ( \
- kSupportsRecordCreationIDMask \
- + kSupportsAttributeCreationIDMask \
- + kSupportsMatchAllMask \
- + kSupportsBeginsWithMask \
- + kSupportsExactMatchMask \
- + kSupportsOrderedEnumerationMask \
- + kCanSupportNameOrderMask \
- + kCanSupportTypeOrderMask \
- + kSupportSortBackwardsMask \
- + kSupportsEnumerationContinueMask \
- + kSupportsLookupContinueMask \
- + kSupportsEnumerateAttributeTypeContinueMask \
- + kSupportsEnumeratePseudonymContinueMask \
- + kSupportsAliasesMask \
- + kSupportsPseudonymsMask \
- + kSupportsFindRecordMask \
- )
-
- #if IsResource == 0
- #ifndef DEBUG_LOG
- #define DEBUG_LOG (kReleaseStage <= betaStage)
- #endif
- #define kNumIcons 6
- #define kAliasBufferSize 0x800
- #define kMyAccessMask ( \
- kSeeMask \
- + kAddMask \
- + kDeleteMask \
- + kChangeMask \
- + kRenameMask \
- )
- #define ioBusy (1)
-
- /*
- * Our icons are defined by this structure. A vector of these is in our private
- * driver control block structure.
- */
- typedef struct IconInfo {
- Handle iconData;
- ResType iconType;
- unsigned short iconLength;
- } IconInfo, *IconInfoPtr;
-
- /*
- * This is a linked list of personal catalog files. It is a standard operating
- * system queue. One of these is created for each catalog served by this CSAM.
- */
- typedef struct CatalogInfo {
- QElemPtr qLink; /* Next CatalogInfo element */
- short qType; /* Unused */
- short refNum;
- CreationID creationID;
- DirDiscriminator discriminator;
- DirectoryName directoryName;
- } CatalogInfo, *CatalogInfoPtr;
-
- /*
- * This is stored in the driver control block.
- */
- typedef struct DTSSampleCSAMInfo {
- DirParamBlock dirParamBlock; /* For internal asynch calls */
- DirEnumSpec enumSpec; /* For Find Record calls */
- QHdr requestQueueHdr; /* Queue of pending requests */
- QHdr catalogQHdr; /* Queue of active catalogs */
- IconInfo icons[kNumIcons]; /* -> Icon handles */
- #ifdef THINK_C
- long originalA4; /* A4 when CSAM was opened */
- #endif
- #if DEBUG_LOG
- AuditPtr auditPtr; /* DEBUG */
- #endif
- } DTSSampleCSAMInfo, *DTSSampleCSAMInfoPtr;
-
- /*
- * All functions refer to certain "global" information
- * by defining the following local variables. INFO
- * is the driver's private data block (in DCTL.dCtlStorage)
- */
- #define PARAM (*pb) /* Caller parameter record */
- #define STATUS (PARAM.header.ioResult)
- #define INFO (*infoPtr) /* CSAM private variables */
-
- #if DEBUG_LOG
- /*
- * No side-effects for these -- I'm too lazy to add local variables.
- */
- #define LogText(who, what) \
- Audit(INFO.auditPtr, who, kAuditFormatString, what)
- #define LogTextX(who, what) \
- Audit(GetAuditPtr(kCSAMCreatorID), who, kAuditFormatString, what)
- #define LogStatusX(who, status, msg) do { \
- if (status != noErr) { \
- AuditStatusString( \
- GetAuditPtr(kCSAMCreatorID), \
- who, \
- status, \
- msg \
- ); \
- } \
- } while (0)
- #define LogStatus(who, status, msg) do { \
- if (status != noErr) { \
- AuditStatusString( \
- INFO.auditPtr, \
- who, \
- status, \
- msg \
- ); \
- } \
- } while (0)
- #define LogError(who, status) do { \
- if (status != noErr) { \
- AuditStatusLocation(INFO.auditPtr, who, status); \
- } \
- } while (0)
- #define LogErrorX(who, status) do { \
- if (status != noErr) { \
- AuditStatusLocation( \
- GetAuditPtr(kCSAMCreatorID), who, status); \
- } \
- } while (0)
- #define AuditRString(auditPtr, who, rString) ( \
- Audit((auditPtr), (who), kAuditFormatString, \
- OCERToPString((RString *) (rString))) \
- )
- #define LogRStringX(who, rString) ( \
- AuditRString( \
- GetAuditPtr(kCSAMCreatorID), \
- who, \
- rString \
- ) \
- )
- #define LogRString(who, rString) ( \
- AuditRString( \
- INFO.auditPtr, \
- who, \
- rString \
- ) \
- )
- /*
- * Interface to the Audit subroutine (debugging). Note: these routines
- * use stack space (temporarily).
- */
- void
- AuditLookupGetPB(
- DirParamBlock *pbPtr
- );
- void
- AuditRecordList(
- AuditPtr auditPtr,
- RecordIDPtr *aRecordList,
- unsigned long recordIDCount
- );
- void
- AuditAttributeTypeList(
- AuditPtr auditPtr,
- AttributeTypePtr *attrTypeList,
- unsigned long attrTypeCount
- );
- void
- AuditRecordID(
- AuditPtr auditPtr,
- RecordIDPtr recordIDPtr
- );
- void
- AuditPackedRLIPtr(
- AuditPtr auditPtr,
- PackedRLIPtr rli
- );
- void
- AuditPath(
- AuditPtr auditPtr,
- PackedPathNamePtr thePath
- );
- #define AuditAttributeType(auditPtr, attributeTypePtr) \
- AuditRString(auditPtr, 'Attr', attributeTypePtr)
- void
- AuditLocalRecordID(
- AuditPtr auditPtr,
- LocalRecordIDPtr localRecordIDPtr
- );
- #else
- #define LogText(who, what) /* Nothing */
- #define LogTextX(who, what) /* Nothing */
- #define LogStatusX(who, status, msg) /* Nothing */
- #define LogStatus(who, status, msg) /* Nothing */
- #define LogError(who, status) /* Nothing */
- #define LogErrorX(who, status) /* Nothing */
- #define LogRStringX(who, rString) /* Nothing */
- #define LogRString(who, rString) /* Nothing */
- #define AuditLookupGetPB(pbPtr) /* Nothing */
- #define AuditRecordList(p, a, r) /* Nothing */
- #define AuditAttributeTypeList(a, t, c) /* Nothing */
- #define AuditRecordID(a, r) /* Nothing */
- #define AuditPackedRLIPtr(a, r) /* Nothing */
- #define AuditPath(a, p) /* Nothing */
- #define AuditAttributeType(a, p) /* Nothing */
- #define AuditLocalRecordID(a, p) /* Nothing */
- #endif
-
- /*
- * Prototypes
- */
- /*
- * DisableInterrupts and EnableInterrupts manipulate the 68000 status register.
- * They are expanded inline.
- *
- * unsigned short DisableInterrupts(void) {
- * asm {
- * move sr,d0
- * move #0x2600,sr
- * }
- */
- unsigned short DisableInterrupts(void) = { 0x40C0, 0x46FC, 0x2600 };
- #ifdef THINK_C
- /*
- * Since Think C has a real inline assembler, we can save one or two instructions.
- * Nerd fun.
- */
- #define EnableInterrupts(saveSR) asm { \
- move saveSR,sr \
- }
- #else
- /*
- * Even though the saveSR argument is a short, we must declare the function as a
- * long so that both Think and MPW generate the same code. Otherwise, Think pushes
- * a short and 2(sp) addresses the wrong value. (Guess how I discovered this.)
- * Using the Think C inline defined above also eliminates the problem.
- *
- * void EnableInterrupts(unsigned long saveSR) {
- * asm {
- * move 2(sp),sr
- * }
- */
- void EnableInterrupts(unsigned long saveSR) = { 0x46EF, 0x0002 };
- #endif
-
-
- /*
- * These are calls into our routines from the driver glue.
- * paramBlock User I/O parameter block
- * devCtlEnt Driver control block
- */
- extern OSErr OpenDRVR(
- CntrlParam *paramBlock,
- DCtlPtr devCtlEnt
- );
- extern OSErr PrimeDRVR(
- CntrlParam *paramBlock,
- DCtlPtr devCtlEnt
- );
- extern OSErr ControlDRVR(
- CntrlParam *paramBlock,
- DCtlPtr devCtlEnt
- );
- extern OSErr StatusDRVR(
- CntrlParam *paramBlock,
- DCtlPtr devCtlEnt
- );
- extern OSErr CloseDRVR(
- CntrlParam *paramBlock,
- DCtlPtr devCtlEnt
- );
- /*
- * Add the CSAM to the authentication manager's notification queue.
- */
- OSErr InitAuthNotificationQueue(
- register DTSSampleCSAMInfoPtr infoPtr
- );
-
- /*
- * CSAM Callbacks
- */
- pascal OSErr CSAM_DSProc(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb,
- Boolean async
- );
- pascal OSErr CSAM_DSParseProc(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb,
- Boolean async
- );
- /*
- * Utility
- */
- OSErr GetCSAMIcon(
- DTSSampleCSAMInfoPtr infoPtr,
- short i
- );
-
- QElemPtr DequeueFirst(
- QHdrPtr theQueue
- );
- void CallCompletion(
- ParmBlkPtr pb
- );
-
- void DirParseCommon(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb,
- Boolean async
- );
- void ProcessPDCommands(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb,
- Boolean async
- );
-
- /*
- * Callbacks
- */
- pascal Boolean MyForEachEnumSpec(
- long userPB,
- const DirEnumSpec *enumSpecPtr
- );
- pascal Boolean MyForEachRecordID(
- long userPB,
- const RecordID *rid
- );
- pascal Boolean MyForEachLookupRecordID(
- long userPB,
- const RecordID *rid
- );
- pascal Boolean MyForEachAttrTypeLookup(
- long userPB,
- const AttributeType *parmPtr,
- AccessMask myAttrAccMask
- );
- pascal Boolean MyForEachAttrValue(
- long userPB,
- const Attribute *parmPtr
- );
- pascal Boolean MyForEachAttrType(
- long userPB,
- const AttributeType *parmPtr
- );
- pascal Boolean GetPABFSSpecCB(
- FSSpec *pabSpec,
- const Attribute *thisAttribute
- );
- OSErr AddCatalog(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb
- );
- OSErr RemoveCatalog(
- DTSSampleCSAMInfoPtr infoPtr,
- DirParamBlockPtr pb
- );
- OSErr GetRefNumFromRLI(
- DTSSampleCSAMInfoPtr infoPtr,
- PackedRLI *prli,
- short *refNum
- );
- /*
- * Interface to the Directory Manager functions.
- */
- pascal OSErr ADASOpenPAB(
- FSSpec *spec,
- char permissionsRequested,
- short *refNum
- );
- pascal OSErr ADASClosePAB(
- short refNum
- );
- pascal OSErr ADASGetOCESetupInfo(
- RecordID *rid,
- short *refNum
- );
- pascal OSErr ADASLookupAttributeValue(
- RecordID *rid,
- short dsRefNum,
- AuthIdentity identity,
- long bufferSize,
- Boolean includeStartingPoint,
- AttributeType *attrType,
- const AttributeCreationID *attrCID,
- long clientData,
- ForEachAttrValue eachAttrValue
- );
-
- #endif /* IsResource == 0 */
- #endif /* __DTSSampleCSAM__ */
-
-